package icu.zqyhdm.blog.utils;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

/**
 * @Description 复制两个page的元素，将entity转成Vo
 * @Author lifu
 * @Date 2021/8/18 23:27
 */
public class PageUtil {
    public static<T> Page<T> page(Page<?> page, Class<T> targetType){
        Page<T> targetPage = new Page<>();
        targetPage.setCurrent(page.getCurrent());
        targetPage.setSize(page.getSize());
        targetPage.setTotal(page.getTotal());
        List<?> records = page.getRecords();
        targetPage.setRecords(BeanUtil.copyToList(records, targetType));
        return targetPage;
    }
}
